package com.study2.A01keBianCanShu;

public class A01_Args {
    public static void main(String[] args) {
        System.out.println(getSum(1,2,3,4,5,6,7,8,9,10));
    }
    
    /*public static int getSum(int[] arr){
        int sum = 0;
        for (int i : arr) {
            sum += i;
        }
        return sum;
    }*/
    
    
    /*
    * 最多写一个可变参数
    * 除了可变参数以外还有别的形参 可变参数要写在最后
    * */
    public static int getSum(int... args){
        int sum = 0;
        for (int arg : args) {
            sum += arg;
        }
        return sum;
    }
}
